package com.fancy.learncenter.ui.view;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.PopupWindow;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.BaseBean;
import com.fancy.learncenter.bean.CartoonJoinClassResultBean;
import com.fancy.learncenter.net.CustomNetCallBack;
import com.fancy.learncenter.net.CustomNetSubscriber;
import com.fancy.learncenter.net.HttpMehtod;
import com.fancy.learncenter.ui.activity.CartoonChildHomeActivity;
import com.fancy.learncenter.ui.callback.AddClassPopuImpl;
import com.fancy.learncenter.utils.NetUtil;
import com.fancy.learncenter.utils.ToastUtil;
import com.fancy.learncenter.utils.Utils;

import java.util.HashMap;
import java.util.Map;

import okhttp3.ResponseBody;
import retrofit2.Response;

/**
 * Created by shiweiwei on 2018/1/5.
 */

public class CartoonAddClassPopu extends BasePopupWindow{

    private Activity mContext;
    private ViewGroup layoutView;
    private View rootView;
    private EditText inputClassEdit;
    private ImageView cancelImage;
    private ImageView okImage;

    public void setListener(AddClassPopuImpl listener) {
        this.listener = listener;
    }

    private AddClassPopuImpl listener;
    public CartoonAddClassPopu(Activity mContext, ViewGroup layoutView) {
        super(mContext);
        this.mContext = mContext;
        this.layoutView = layoutView;
        initView();
    }

    private void initView(){

        rootView = LayoutInflater.from(mContext).inflate(R.layout.popu_cartoon_add_class,null);
        inputClassEdit = (EditText) rootView.findViewById(R.id.input_class_edit);
        cancelImage = (ImageView) rootView.findViewById(R.id.cancel);
        okImage = (ImageView) rootView.findViewById(R.id.ok);
        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        setFocusable(true); //安卓中PopupWindow中的EditText无法弹出软键盘解决
        setContentView(rootView);


        cancelImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (listener != null){
                    listener.cancelClick();
                }
            }
        });

        okImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (listener != null){
                    listener.okClick(inputClassEdit.getText().toString());
                }
            }
        });

    }



    @Override
    public void showPopupWindow() {
        super.showPopupWindow();

        showAtLocation(layoutView, Gravity.CENTER, 0, 0);
    }



}
